<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Linux 文件目录管理 | 知识库</title>
    <meta name="generator" content="VuePress 1.9.2">
    <link rel="icon" href="/vuepress-theme-vdoing-doc/img/favicon.ico">
    <noscript><meta http-equiv="refresh" content="0; url=https://www.youngkbt.cn/noscript/"><style>.theme-vdoing-content { display:none }</noscript>
    <meta name="description" content="一个基于VuePress的 知识管理">
    <meta name="keywords" content="vuepress,theme,blog,vdoing">
    <meta name="theme-color" content="#11a8cd">
    
    <link rel="preload" href="/vuepress-theme-vdoing-doc/assets/css/0.styles.b0974950.css" as="style"><link rel="preload" href="/vuepress-theme-vdoing-doc/assets/js/app.f061d58b.js" as="script"><link rel="preload" href="/vuepress-theme-vdoing-doc/assets/js/2.9bf30e88.js" as="script"><link rel="preload" href="/vuepress-theme-vdoing-doc/assets/js/71.02806218.js" as="script"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/10.d2937c56.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/11.67567365.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/12.74e8c324.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/13.2376fcd7.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/14.57ef5c33.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/15.44e7c0ba.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/16.c2fb4c44.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/17.af212389.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/18.1e6acac7.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/19.54653ac9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/20.920cc499.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/21.37128fe3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/22.8f68a2f2.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/23.7b9f1ba6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/24.12adc291.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/25.cfe381e5.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/26.9cf879f6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/27.4e6190ea.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/28.1e22fc79.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/29.c57e047d.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/3.cdcce428.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/30.21a95474.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/31.ce97e6e3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/32.cdb45d73.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/33.fd95e780.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/34.cd49a408.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/35.fe128161.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/36.02043ece.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/37.02eee249.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/38.4650dec6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/39.04fb7652.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/4.c02b1e5f.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/40.7b51f807.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/41.1df513a9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/42.92a82cec.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/43.363fceef.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/44.867b24fd.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/45.89f64bfa.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/46.3a4c53d8.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/47.b8a31c80.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/48.7a584b38.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/49.98345029.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/5.cb45b2c7.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/50.6a0b68f4.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/51.8945cdf6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/52.6583e327.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/53.f6987dfc.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/54.cca012f3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/55.8c58cf5c.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/56.23e08364.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/57.08b54de0.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/58.131ee23e.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/59.45637607.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/6.c97c5dc9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/60.fe9c5dd1.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/61.39ad8fda.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/62.ede47d34.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/63.4bb3e179.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/64.23f955bc.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/65.77ffc240.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/66.a4503c94.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/67.bd3d6fa6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/68.a003ac59.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/69.64c66f41.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/7.1e88af32.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/70.87dfbf7d.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/72.54e30335.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/73.002db3b4.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/74.e577570e.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/75.e610b3c9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/76.f684a067.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/77.8be17062.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/78.cabc6873.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/79.83febd7c.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/8.91701106.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/80.19e3b7ca.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/81.1b4cafb3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/82.752ef803.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/83.460cd49b.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/84.377a221f.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/85.016eaf98.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/86.604c5deb.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/87.d3a3662d.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/88.0cf7f581.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/89.40b002bd.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/9.94309dfb.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/90.086847f8.js">
    <link rel="stylesheet" href="/vuepress-theme-vdoing-doc/assets/css/0.styles.b0974950.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/vuepress-theme-vdoing-doc/" class="home-link router-link-active"><img src="/vuepress-theme-vdoing-doc/img/logo.png" alt="知识库" class="logo"> <span class="site-name can-hide">知识库</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/vuepress-theme-vdoing-doc/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="link-title">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/52d5c3/" class="nav-link">主题初衷与诞生</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="nav-link">介绍</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e08c97/" class="nav-link">模板集</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="案例" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="link-title">案例</a> <span class="title" style="display:none;">案例</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="nav-link">01.后端.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/4bd4c3/" class="nav-link">02.前端.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Docker" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="link-title">Docker</a> <span class="title" style="display:none;">Docker</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="nav-link">Docker安装与卸载</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ceaf16/" class="nav-link">Docker常用命令</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Linux" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/489582/" class="link-title">Linux</a> <span class="title" style="display:none;">Linux</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/489582/" class="nav-link">01.防火墙设置.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/6babae/" class="nav-link">02.Linux文件压缩和解压要点.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ccdc52/" aria-current="page" class="nav-link router-link-exact-active router-link-active">03.Linux 文件目录管理.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/503b98/" class="nav-link">04.Linux 文件内容查看编辑.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e7b850/" class="nav-link">05.Linux 网络管理.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="空间聚合" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="link-title">空间聚合</a> <span class="title" style="display:none;">空间聚合</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="nav-link">OGC标准函数</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/fcb182/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>MyBatis</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/01e8a8/" class="nav-link">01.XML 映射器.md</a></li></ul></li><li class="dropdown-item"><h4>国产数据库</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3c4d09/" class="nav-link">01.达梦适配.md</a></li><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3ab660/" class="nav-link">02.瀚高适配.md</a></li></ul></li><li class="dropdown-item"><h4>Selenium爬取数据</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/e110c2/" class="nav-link">spring boot+selenium爬取数据.md</a></li></ul></li></ul></div></div> <a href="https://gitee.com/" target="_blank" rel="noopener noreferrer" class="repo-link">
    Source
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/vuepress-theme-vdoing-doc/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="link-title">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/52d5c3/" class="nav-link">主题初衷与诞生</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="nav-link">介绍</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e08c97/" class="nav-link">模板集</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="案例" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="link-title">案例</a> <span class="title" style="display:none;">案例</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="nav-link">01.后端.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/4bd4c3/" class="nav-link">02.前端.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Docker" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="link-title">Docker</a> <span class="title" style="display:none;">Docker</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="nav-link">Docker安装与卸载</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ceaf16/" class="nav-link">Docker常用命令</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Linux" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/489582/" class="link-title">Linux</a> <span class="title" style="display:none;">Linux</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/489582/" class="nav-link">01.防火墙设置.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/6babae/" class="nav-link">02.Linux文件压缩和解压要点.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ccdc52/" aria-current="page" class="nav-link router-link-exact-active router-link-active">03.Linux 文件目录管理.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/503b98/" class="nav-link">04.Linux 文件内容查看编辑.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e7b850/" class="nav-link">05.Linux 网络管理.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="空间聚合" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="link-title">空间聚合</a> <span class="title" style="display:none;">空间聚合</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="nav-link">OGC标准函数</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/fcb182/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>MyBatis</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/01e8a8/" class="nav-link">01.XML 映射器.md</a></li></ul></li><li class="dropdown-item"><h4>国产数据库</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3c4d09/" class="nav-link">01.达梦适配.md</a></li><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3ab660/" class="nav-link">02.瀚高适配.md</a></li></ul></li><li class="dropdown-item"><h4>Selenium爬取数据</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/e110c2/" class="nav-link">spring boot+selenium爬取数据.md</a></li></ul></li></ul></div></div> <a href="https://gitee.com/" target="_blank" rel="noopener noreferrer" class="repo-link">
    Source
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <div class="sidebar-slot sidebar-slot-top">
  <a href="http://apifox.cn/a103xugaoyi" target="_blank">
<!--    <img src="https://cdn.staticaly.com/gh/xugaoyi/blog-gitalk-comment@master/img/431669861564_.2470ykdcpbds.jpg" alt="npm" class="no-zoom" style="width: 100%;border-radius: 2px;">-->
<!--    <p style="text-align: center;margin: 0;color: #999;font-size: 12px;">(进入注册为作者充电)</p>-->
  </a></div> <ul class="sidebar-links"><li><a href="/vuepress-theme-vdoing-doc/pages/489582/" class="sidebar-link">防火墙设置</a></li><li><a href="/vuepress-theme-vdoing-doc/pages/6babae/" class="sidebar-link">Linux文件压缩和解压要点</a></li><li><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/" aria-current="page" class="active sidebar-link">Linux 文件目录管理</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_1-linux-文件目录工作机制" class="sidebar-link">1. Linux 文件目录工作机制</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_1-1-linux-目录结构" class="sidebar-link">1.1. Linux 目录结构</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_1-2-linux-文件属性" class="sidebar-link">1.2. Linux 文件属性</a></li><li class="sidebar-sub-header level4"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_1-2-1-linux-文件属主和属组" class="sidebar-link">1.2.1. Linux 文件属主和属组</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_2-linux-文件目录管理要点" class="sidebar-link">2. Linux 文件目录管理要点</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_2-1-目录管理" class="sidebar-link">2.1. 目录管理</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_2-2-文件管理" class="sidebar-link">2.2. 文件管理</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_2-3-文件和目录通用管理" class="sidebar-link">2.3. 文件和目录通用管理</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-命令常见用法" class="sidebar-link">3. 命令常见用法</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-1-cd" class="sidebar-link">3.1. cd</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-2-ls" class="sidebar-link">3.2. ls</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-3-pwd" class="sidebar-link">3.3. pwd</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-4-mkdir" class="sidebar-link">3.4. mkdir</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-5-rmdir" class="sidebar-link">3.5. rmdir</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-6-tree" class="sidebar-link">3.6. tree</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-7-touch" class="sidebar-link">3.7. touch</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-8-ln" class="sidebar-link">3.8. ln</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-9-rename" class="sidebar-link">3.9. rename</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-10-stat" class="sidebar-link">3.10. stat</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-11-file" class="sidebar-link">3.11. file</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-12-chmod" class="sidebar-link">3.12. chmod</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-13-chown" class="sidebar-link">3.13. chown</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-14-locate" class="sidebar-link">3.14. locate</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-15-find" class="sidebar-link">3.15. find</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-16-cp" class="sidebar-link">3.16. cp</a></li><li class="sidebar-sub-header level4"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-16-1-参数" class="sidebar-link">3.16.1. 参数</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-17-scp" class="sidebar-link">3.17. scp</a></li><li class="sidebar-sub-header level4"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-17-1-免密码传输" class="sidebar-link">3.17.1. 免密码传输</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-18-mv" class="sidebar-link">3.18. mv</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/#_3-19-rm" class="sidebar-link">3.19. rm</a></li></ul></li></ul></li><li><a href="/vuepress-theme-vdoing-doc/pages/503b98/" class="sidebar-link">Linux 文件内容查看编辑</a></li><li><a href="/vuepress-theme-vdoing-doc/pages/e7b850/" class="sidebar-link">Linux 网络管理</a></li><li><a href="/vuepress-theme-vdoing-doc/pages/c7033b/" class="sidebar-link">系统磁盘扩容</a></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/vuepress-theme-vdoing-doc/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><span data-v-06225672>linux</span></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="https://gitee.com/wenlongjia" target="_blank" title="作者" class="beLink" data-v-06225672>Insist</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2023-05-25</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">Linux 文件目录管理<!----></h1> <div class="page-slot page-slot-top">
    <div class="wwads-cn wwads-horizontal page-wwads" data-id="136"></div>
    <style>
      .page-wwads{
        width:100%!important;
        min-height: 0;
        margin: 0;
      }
      .page-wwads .wwads-img img{
        width:80px!important;
      }
      .page-wwads .wwads-poweredby{
        width: 40px;
        position: absolute;
        right: 25px;
        bottom: 3px;
      }
      .wwads-content .wwads-text, .page-wwads .wwads-text{
        height: 100%;
        padding-top: 5px;
        display: block;
      }
  </style>
  </div> <div class="theme-vdoing-content content__default"><h1 id="linux-文件目录管理"><a href="#linux-文件目录管理" class="header-anchor">#</a> Linux 文件目录管理</h1> <blockquote><p>关键词：<code>cd</code>, <code>ls</code>, <code>pwd</code>, <code>mkdir</code>, <code>rmdir</code>, <code>tree</code>, <code>touch</code>, <code>ln</code>, <code>rename</code>, <code>stat</code>, <code>file</code>, <code>chmod</code>, <code>chown</code>, <code>locate</code>, <code>find</code>, <code>cp</code>, <code>scp</code>, <code>mv</code>, <code>rm</code></p></blockquote> <h2 id="_1-linux-文件目录工作机制"><a href="#_1-linux-文件目录工作机制" class="header-anchor">#</a> 1. Linux 文件目录工作机制</h2> <h3 id="_1-1-linux-目录结构"><a href="#_1-1-linux-目录结构" class="header-anchor">#</a> 1.1. Linux 目录结构</h3> <p>linux 目录结构是树形结构，其根目录是 <code>/</code> 。一张思维导图说明各个目录的作用：</p> <p><img src="https://raw.githubusercontent.com/dunwu/images/dev/cs/os/linux/linux-folders.png" alt="img"></p> <h3 id="_1-2-linux-文件属性"><a href="#_1-2-linux-文件属性" class="header-anchor">#</a> 1.2. Linux 文件属性</h3> <p>Linux 系统是一种典型的多用户系统，不同的用户处于不同的地位，拥有不同的权限。为了保护系统的安全性，Linux 系统对不同的用户访问同一文件（包括目录文件）的权限做了不同的规定。
在 Linux 中我们可以使用 ll 或者 ls –l 命令来显示一个文件的属性以及文件所属的用户和组，如：</p> <div class="language-bash extra-class"><pre class="language-bash"><code>$ <span class="token function">ls</span> <span class="token parameter variable">-l</span>
total <span class="token number">64</span>
dr-xr-xr-x <span class="token number">2</span> root root <span class="token number">4096</span> Dec <span class="token number">14</span> <span class="token number">2012</span> bin
dr-xr-xr-x <span class="token number">4</span> root root <span class="token number">4096</span> Apr <span class="token number">19</span> <span class="token number">2012</span> boot
</code></pre></div><p>实例中，bin 文件的第一个属性用 <code>d</code> 表示。<code>d</code> 在 Linux 中代表该文件是一个目录文件。
在 Linux 中第一个字符代表这个文件是目录、文件或链接文件等等。</p> <ul><li>当为 <code>d</code> 则是目录</li> <li>当为 <code>-</code> 则是文件；</li> <li>若是 <code>l</code> 则表示为链接文档(link file)；</li> <li>若是 <code>b</code> 则表示为装置文件里面的可供储存的接口设备(可随机存取装置)；</li> <li>若是 <code>c</code> 则表示为装置文件里面的串行端口设备，例如键盘、鼠标(一次性读取装置)。</li></ul> <p>接下来的字符中，以三个为一组，且均为『rwx』 的三个参数的组合。其中，<code>r</code> 代表可读(read)、<code>w</code> 代表可写(write)、<code>x</code> 代表可执行(execute)。 要注意的是，这三个权限的位置不会改变，如果没有权限，就会出现减号 <code>-</code> 而已。</p> <p>每个文件的属性由左边第一部分的 10 个字符来确定（如下图）。</p> <p><img src="https://raw.githubusercontent.com/dunwu/images/dev/snap/20180920180927171909.png" alt="img"></p> <p>从左至右用 0-9 这些数字来表示。</p> <ul><li>第 0 位确定文件类型</li> <li>第 1-3 位确定属主（该文件的拥有者）拥有该文件的权限。</li> <li>第 4-6 位确定属组（拥有者的同组用户）拥有该文件的权限。</li> <li>第 7-9 位确定其他用户拥有该文件的权限。</li> <li>第 1、4、7 位表示读权限，如果用&quot;r&quot;字符表示，则有读权限，如果用&quot;-&quot;字符表示，则没有读权限。</li> <li>第 2、5、8 位表示写权限，如果用&quot;w&quot;字符表示，则有写权限，如果用&quot;-&quot;字符表示没有写权限。</li> <li>第 3、6、9 位表示可执行权限，如果用&quot;x&quot;字符表示，则有执行权限，如果用&quot;-&quot;字符表示，则没有执行权限。</li></ul> <h4 id="_1-2-1-linux-文件属主和属组"><a href="#_1-2-1-linux-文件属主和属组" class="header-anchor">#</a> 1.2.1. Linux 文件属主和属组</h4> <div class="language-bash extra-class"><pre class="language-bash"><code>$ <span class="token function">ls</span> <span class="token parameter variable">-l</span>
total <span class="token number">64</span>
dr-xr-xr-x   <span class="token number">2</span> root root <span class="token number">4096</span> Dec <span class="token number">14</span>  <span class="token number">2012</span> bin
dr-xr-xr-x   <span class="token number">4</span> root root <span class="token number">4096</span> Apr <span class="token number">19</span>  <span class="token number">2012</span> boot
</code></pre></div><ul><li>对于文件来说，它都有一个特定的拥有者，也就是对该文件具有所有权的用户。</li> <li>同时，在 Linux 系统中，用户是按组分类的，一个用户属于一个或多个组。</li> <li>文件拥有者以外的用户又可以分为文件拥有者的同组用户和其他用户。</li> <li>因此，Linux 系统按文件拥有者、文件拥有者同组用户和其他用户来规定了不同的文件访问权限。</li> <li>在以上实例中，bin 文件是一个目录文件，属主和属组都为 root，属主有可读、可写、可执行的权限；与属主同组的其他用户有可读和可执行的权限；其他用户也有可读和可执行的权限。</li></ul> <h2 id="_2-linux-文件目录管理要点"><a href="#_2-linux-文件目录管理要点" class="header-anchor">#</a> 2. Linux 文件目录管理要点</h2> <h3 id="_2-1-目录管理"><a href="#_2-1-目录管理" class="header-anchor">#</a> 2.1. 目录管理</h3> <ul><li>切换目录 - 使用 <a href="#cd">cd</a></li> <li>查看目录信息 - 使用 <a href="#ls">ls</a></li> <li>显示当前目录的绝对路径 - 使用 <a href="#pwd">pwd</a></li> <li>树状显示目录的内容 - 使用 <a href="#tree">tree</a></li> <li>创建目录 - 使用 <a href="#mkdir">mkdir</a></li> <li>删除目录 - 使用 <a href="#rmdir">rmdir</a></li></ul> <h3 id="_2-2-文件管理"><a href="#_2-2-文件管理" class="header-anchor">#</a> 2.2. 文件管理</h3> <ul><li>创建空文件 - 使用 <a href="#touch">touch</a></li> <li>为文件创建连接 - 使用 <a href="#ln">ln</a></li> <li>批量重命名 - 使用 <a href="#rename">rename</a></li> <li>显示文件的详细信息 - 使用 <a href="#stat">stat</a></li> <li>探测文件类型 - 使用 <a href="#file">file</a></li> <li>设置文件或目录的权限 - 使用 <a href="#chmod">chmod</a></li> <li>设置文件或目录的拥有者或所属群组 - 使用 <a href="#chown">chown</a></li> <li>查找文件或目录 - 使用 <a href="#locate">locate</a></li> <li>在指定目录下查找文件 - 使用 <a href="#find">find</a></li> <li>查找命令的绝对路径 - 使用 <a href="#which">which</a></li> <li>查找命令的程序、源代码等相关文件 - 使用 <a href="#whereis">whereis</a></li></ul> <h3 id="_2-3-文件和目录通用管理"><a href="#_2-3-文件和目录通用管理" class="header-anchor">#</a> 2.3. 文件和目录通用管理</h3> <ul><li>复制文件或目录 - 使用 <a href="#cp">cp</a></li> <li>复制文件或目录到远程服务器 - 使用 <a href="#scp">scp</a></li> <li>移动文件或目录 - 使用 <a href="#mv">mv</a></li> <li>删除文件或目录 - 使用 <a href="#rm">rm</a></li></ul> <h2 id="_3-命令常见用法"><a href="#_3-命令常见用法" class="header-anchor">#</a> 3. 命令常见用法</h2> <h3 id="_3-1-cd"><a href="#_3-1-cd" class="header-anchor">#</a> 3.1. cd</h3> <blockquote><p>cd 命令用来切换工作目录。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token builtin class-name">cd</span>          <span class="token comment"># 切换到用户主目录</span>
<span class="token builtin class-name">cd</span> ~        <span class="token comment"># 切换到用户主目录</span>
<span class="token builtin class-name">cd</span> -        <span class="token comment"># 切换到上一个工作目录</span>
<span class="token builtin class-name">cd</span> <span class="token punctuation">..</span>       <span class="token comment"># 切换到上级目录</span>
<span class="token builtin class-name">cd</span> <span class="token punctuation">..</span>/<span class="token punctuation">..</span>    <span class="token comment"># 切换到上两级目录</span>
</code></pre></div><h3 id="_3-2-ls"><a href="#_3-2-ls" class="header-anchor">#</a> 3.2. ls</h3> <blockquote><p>ls 命令用来显示目录信息。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">ls</span>        <span class="token comment"># 列出当前目录可见文件</span>
<span class="token function">ls</span> <span class="token parameter variable">-l</span>     <span class="token comment"># 列出当前目录可见文件详细信息</span>
<span class="token function">ls</span> <span class="token parameter variable">-la</span>    <span class="token comment"># 列出所有文件（包括隐藏）的详细信息</span>
<span class="token function">ls</span> <span class="token parameter variable">-lh</span>    <span class="token comment"># 列出详细信息并以可读大小显示文件大小</span>
<span class="token function">ls</span> <span class="token parameter variable">-lt</span>    <span class="token comment"># 按时间列出文件和文件夹详细信息</span>
<span class="token function">ls</span> <span class="token parameter variable">-ltr</span>   <span class="token comment"># 按修改时间列出文件和文件夹详细信息</span>
<span class="token function">ls</span> <span class="token parameter variable">--color</span><span class="token operator">=</span>auto     <span class="token comment"># 列出文件并标记颜色分类</span>
</code></pre></div><h3 id="_3-3-pwd"><a href="#_3-3-pwd" class="header-anchor">#</a> 3.3. pwd</h3> <blockquote><p>pwd 命令用来显示当前目录的绝对路径。</p></blockquote> <h3 id="_3-4-mkdir"><a href="#_3-4-mkdir" class="header-anchor">#</a> 3.4. mkdir</h3> <blockquote><p>mkdir 命令用来创建目录。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 在当前目录中创建 zp 和 zp 的子目录 test</span>
<span class="token function">mkdir</span> <span class="token parameter variable">-p</span> zp/test

<span class="token comment"># 在当前目录中创建 zp 和 zp 的子目录 test；权限设置为文件主可读、写、执行，同组用户可读和执行，其他用户无权访问</span>
<span class="token function">mkdir</span> <span class="token parameter variable">-p</span> <span class="token parameter variable">-m</span> <span class="token number">750</span> zp/test
</code></pre></div><h3 id="_3-5-rmdir"><a href="#_3-5-rmdir" class="header-anchor">#</a> 3.5. rmdir</h3> <blockquote><p>rmdir 命令用来删除空目录。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 删除子目录 test 和其父目录 zp</span>
<span class="token function">rmdir</span> <span class="token parameter variable">-p</span> zp/test
</code></pre></div><h3 id="_3-6-tree"><a href="#_3-6-tree" class="header-anchor">#</a> 3.6. tree</h3> <blockquote><p>tree 命令以树状显示目录的内。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 列出目录 /private 第一级文件名</span>
tree /private <span class="token parameter variable">-L</span> <span class="token number">1</span>
/private/
├── etc
├── tftpboot
├── tmp
└── var

<span class="token comment"># 忽略文件夹</span>
tree <span class="token parameter variable">-I</span> node_modules            <span class="token comment"># 忽略当前目录文件夹 node_modules</span>
tree <span class="token parameter variable">-P</span> node_modules            <span class="token comment"># 列出当前目录文件夹 node_modules 的目录结构</span>
tree <span class="token parameter variable">-P</span> node_modules <span class="token parameter variable">-L</span> <span class="token number">2</span>       <span class="token comment"># 显示目录 node_modules 两层的目录树结构</span>
tree <span class="token parameter variable">-L</span> <span class="token number">2</span> <span class="token operator">&gt;</span> /home/www/tree.txt  <span class="token comment"># 当前目录结果存到 tree.txt 文件中</span>

<span class="token comment"># 忽略多个文件夹</span>
tree <span class="token parameter variable">-I</span> <span class="token string">'node_modules|icon|font'</span> <span class="token parameter variable">-L</span> <span class="token number">2</span>
</code></pre></div><h3 id="_3-7-touch"><a href="#_3-7-touch" class="header-anchor">#</a> 3.7. touch</h3> <blockquote><p>touch 命令有两个功能：一是用于把已存在文件的时间标签更新为系统当前的时间（默认方式），它们的数据将原封不动地保留下来；二是用来创建空文件。</p></blockquote> <p>示例：</p> <div class="language- extra-class"><pre class="language-text"><code>touch ex2
</code></pre></div><h3 id="_3-8-ln"><a href="#_3-8-ln" class="header-anchor">#</a> 3.8. ln</h3> <blockquote><p>ln 命令用来为文件创建连接，连接类型分为硬连接和符号连接两种，默认的连接类型是硬连接。如果要创建符号连接必须使用&quot;-s&quot;选项。</p> <p>🔔 注意：符号链接文件不是一个独立的文件，它的许多属性依赖于源文件，所以给符号链接文件设置存取权限是没有意义的。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 将目录 /usr/mengqc/mub1 下的文件 m2.c 链接到目录 /usr/liu 下的文件 a2.c</span>
<span class="token builtin class-name">cd</span> /usr/mengqc
<span class="token function">ln</span> /mub1/m2.c /usr/liu/a2.c

<span class="token comment"># 在目录 /usr/liu 下建立一个符号链接文件 abc，使它指向目录 /usr/mengqc/mub1</span>
<span class="token comment"># 执行该命令后，/usr/mengqc/mub1 代表的路径将存放在名为 /usr/liu/abc 的文件中</span>
<span class="token function">ln</span> <span class="token parameter variable">-s</span> /usr/mengqc/mub1 /usr/liu/abc
</code></pre></div><h3 id="_3-9-rename"><a href="#_3-9-rename" class="header-anchor">#</a> 3.9. rename</h3> <blockquote><p>rename 命令用字符串替换的方式批量重命名。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 将 main1.c 重命名为 main.c</span>
<span class="token function">rename</span> main1.c main.c main1.c

<span class="token function">rename</span> <span class="token string">&quot;s/AA/aa/&quot;</span> *             <span class="token comment"># 把文件名中的 AA 替换成 aa</span>
<span class="token function">rename</span> <span class="token string">&quot;s//.html//.php/&quot;</span> *      <span class="token comment"># 把 .html 后缀的改成 .php 后缀</span>
<span class="token function">rename</span> <span class="token string">&quot;s/$//.txt/&quot;</span> *           <span class="token comment"># 把所有的文件名都以 txt 结尾</span>
<span class="token function">rename</span> <span class="token string">&quot;s//.txt//&quot;</span> *            <span class="token comment"># 把所有以 .txt 结尾的文件名的.txt 删掉</span>
</code></pre></div><h3 id="_3-10-stat"><a href="#_3-10-stat" class="header-anchor">#</a> 3.10. stat</h3> <blockquote><p>stat 命令用于显示文件的状态信息。stat 命令的输出信息比 ls 命令的输出信息要更详细。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">stat</span> myfile
</code></pre></div><h3 id="_3-11-file"><a href="#_3-11-file" class="header-anchor">#</a> 3.11. file</h3> <blockquote><p>file 命令用来探测给定文件的类型。file 命令对文件的检查分为文件系统、魔法幻数检查和语言检查 3 个过程。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">file</span> install.log          <span class="token comment"># 显示文件类型</span>
<span class="token function">file</span> <span class="token parameter variable">-b</span> install.log       <span class="token comment"># 不显示文件名称</span>
<span class="token function">file</span> <span class="token parameter variable">-i</span> install.log       <span class="token comment"># 显示 MIME 类型</span>
<span class="token function">file</span> <span class="token parameter variable">-L</span> /var/spool/mail   <span class="token comment"># 显示符号链接的文件类型</span>
</code></pre></div><h3 id="_3-12-chmod"><a href="#_3-12-chmod" class="header-anchor">#</a> 3.12. chmod</h3> <blockquote><p>chmod 命令用来变更文件或目录的权限。在 UNIX 系统家族里，文件或目录权限的控制分别以读取、写入、执行 3 种一般权限来区分，另有 3 种特殊权限可供运用。用户可以使用 chmod 指令去变更文件与目录的权限，设置方式采用文字或数字代号皆可。符号连接的权限无法变更，如果用户对符号连接修改权限，其改变会作用在被连接的原始文件。</p></blockquote> <p>知识扩展：</p> <p>Linux 用 户分为：拥有者、组群(Group)、其他（other），Linux 系统中，预设的情況下，系统中所有的帐号与一般身份使用者，以及 root 的相关信 息， 都是记录在<code>/etc/passwd</code>文件中。每个人的密码则是记录在<code>/etc/shadow</code>文件下。 此外，所有的组群名称记录在<code>/etc/group</code>內！</p> <p>linux 文件的用户权限的分析图</p> <div class="language-bash extra-class"><pre class="language-bash"><code>  -rw-r--r--   <span class="token number">1</span> user  staff   <span class="token number">651</span> Oct <span class="token number">12</span> <span class="token number">12</span>:53 .gitmodules
<span class="token comment"># ↑╰┬╯╰┬╯╰┬╯</span>
<span class="token comment"># ┆ ┆  ┆  ╰┈ 0 其他人</span>
<span class="token comment"># ┆ ┆  ╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ g 属组</span>
<span class="token comment"># ┆ ╰┈┈┈┈ u 属组</span>
<span class="token comment"># ╰┈┈ 第一个字母 `d` 代表目录，`-` 代表普通文件</span>
</code></pre></div><p>例：rwx 　 rw-　 r--</p> <p>r=读取属性　　//值＝ 4<br>
w=写入属性　　//值＝ 2<br>
x=执行属性　　//值＝ 1</p> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">chmod</span> u+x,g+w f01　　<span class="token comment"># 为文件f01设置自己可以执行，组员可以写入的权限</span>
<span class="token function">chmod</span> <span class="token assign-left variable">u</span><span class="token operator">=</span>rwx,g<span class="token operator">=</span>rw,o<span class="token operator">=</span>r f01
<span class="token function">chmod</span> <span class="token number">764</span> f01
<span class="token function">chmod</span> a+x f01　　    <span class="token comment"># 对文件f01的u,g,o都设置可执行属性</span>

<span class="token comment"># 将/home/wwwroot/里的所有文件和文件夹设置为755权限</span>
<span class="token function">chmod</span> <span class="token parameter variable">-R</span>  <span class="token number">755</span> /home/wwwroot/*
</code></pre></div><h3 id="_3-13-chown"><a href="#_3-13-chown" class="header-anchor">#</a> 3.13. chown</h3> <blockquote><p>chown 命令改变某个文件或目录的所有者和所属的组，该命令可以向某个用户授权，使该用户变成指定文件的所有者或者改变文件所属的组。用户可以是用户或者是用户 D，用户组可以是组名或组 id。文件名可以使由空格分开的文件列表，在文件名中可以包含通配符。</p> <p>只有文件拥有者和超级用户才可以便用该命令。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 将目录/usr/meng及其下面的所有文件、子目录的文件主改成 liu</span>
<span class="token function">chown</span> <span class="token parameter variable">-R</span> liu /usr/meng
</code></pre></div><h3 id="_3-14-locate"><a href="#_3-14-locate" class="header-anchor">#</a> 3.14. locate</h3> <blockquote><p>locate 命令和 slocate 命令都用来查找文件或目录。</p> <p>locate 命令其实是 find -name 的另一种写法，但是要比后者快得多，原因在于它不搜索具体目录，而是搜索一个数据库/var/lib/locatedb，这个数据库中含有本地所有文件信息。Linux 系统自动创建这个数据库，并且每天自动更新一次，所以使用 locate 命令查不到最新变动过的文件。为了避免这种情况，可以在使用 locate 之前，先使用 updatedb 命令，手动更新数据库。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">locate</span> <span class="token builtin class-name">pwd</span>      <span class="token comment"># 查找和 pwd 相关的所有文件</span>
<span class="token function">locate</span> /etc/sh  <span class="token comment"># 搜索 etc 目录下所有以 sh 开头的文件</span>
</code></pre></div><h3 id="_3-15-find"><a href="#_3-15-find" class="header-anchor">#</a> 3.15. find</h3> <blockquote><p>find 命令用来在指定目录下查找文件。任何位于参数之前的字符串都将被视为欲查找的目录名。如果使用该命令时，不设置任何参数，则 find 命令将在当前目录下查找子目录与文件。并且将查找到的子目录和文件全部进行显示。</p></blockquote> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 当前目录搜索所有文件，文件内容 包含 “140.206.111.111” 的内容</span>
<span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-name</span> <span class="token string">&quot;*&quot;</span> <span class="token operator">|</span> <span class="token function">xargs</span> <span class="token function">grep</span> <span class="token string">&quot;140.206.111.111&quot;</span>

<span class="token comment"># 列出当前目录及子目录下所有文件和文件夹</span>
<span class="token function">find</span> <span class="token builtin class-name">.</span>

<span class="token comment"># 在 /home 目录下查找以 .txt 结尾的文件名</span>
<span class="token function">find</span> /home <span class="token parameter variable">-name</span> <span class="token string">&quot;*.txt&quot;</span>
<span class="token comment"># 同上，但忽略大小写</span>
<span class="token function">find</span> /home <span class="token parameter variable">-iname</span> <span class="token string">&quot;*.txt&quot;</span>

<span class="token comment"># 当前目录及子目录下查找所有以 .txt 和 .pdf 结尾的文件</span>
<span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-name</span> <span class="token string">&quot;*.txt&quot;</span> <span class="token parameter variable">-o</span> <span class="token parameter variable">-name</span> <span class="token string">&quot;*.pdf&quot;</span>

<span class="token comment"># 匹配文件路径或者文件</span>
<span class="token function">find</span> /usr/ <span class="token parameter variable">-path</span> <span class="token string">&quot;*local*&quot;</span>

<span class="token comment"># 基于正则表达式匹配文件路径</span>
<span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-regex</span> <span class="token string">&quot;.*\(\.txt\|\.pdf\)$&quot;</span>
<span class="token comment"># 同上，但忽略大小写</span>
<span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-iregex</span> <span class="token string">&quot;.*\(\.txt\|\.pdf\)$&quot;</span>

<span class="token comment"># 找出 /home 下不是以 .txt 结尾的文件</span>
<span class="token function">find</span> /home <span class="token operator">!</span> <span class="token parameter variable">-name</span> <span class="token string">&quot;*.txt&quot;</span>
</code></pre></div><h3 id="_3-16-cp"><a href="#_3-16-cp" class="header-anchor">#</a> 3.16. cp</h3> <blockquote><p>cp 命令用来将一个或多个源文件或者目录复制到指定的目的文件或目录。它可以将单个源文件复制成一个指定文件名的具体的文件或一个已经存在的目录下。cp 命令还支持同时复制多个文件，当一次复制多个文件时，目标文件参数必须是一个已经存在的目录，否则将出现错误。</p></blockquote> <p>示例：</p> <h4 id="_3-16-1-参数"><a href="#_3-16-1-参数" class="header-anchor">#</a> 3.16.1. 参数</h4> <ul><li>源文件：制定源文件列表。默认情况下，cp 命令不能复制目录，如果要复制目录，则必须使用<code>-R</code>选项；</li> <li>目标文件：指定目标文件。当“源文件”为多个文件时，要求“目标文件”为指定的目录。</li></ul> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 将文件 file 复制到目录 /usr/men/tmp 下，并改名为 file1</span>
<span class="token function">cp</span> <span class="token function">file</span> /usr/men/tmp/file1

<span class="token comment"># 将目录 /usr/men下的所有文件及其子目录复制到目录 /usr/zh 中</span>
<span class="token function">cp</span> <span class="token parameter variable">-r</span> /usr/men /usr/zh

<span class="token comment"># 强行将 /usr/men下的所有文件复制到目录 /usr/zh 中，无论是否有文件重复</span>
<span class="token function">cp</span> <span class="token parameter variable">-rf</span> /usr/men/* /usr/zh

<span class="token comment"># 将目录 /usr/men 中的以 m 打头的所有 .c 文件复制到目录 /usr/zh 中</span>
<span class="token function">cp</span> <span class="token parameter variable">-i</span> /usr/men m*.c /usr/zh
</code></pre></div><h3 id="_3-17-scp"><a href="#_3-17-scp" class="header-anchor">#</a> 3.17. scp</h3> <blockquote><p>scp 命令用于在 Linux 下进行远程拷贝文件的命令，和它类似的命令有 cp，不过 cp 只是在本机进行拷贝不能跨服务器，而且 scp 传输是加密的。可能会稍微影响一下速度。当你服务器硬盘变为只读 read only system 时，用 scp 可以帮你把文件移出来。另外，scp 还非常不占资源，不会提高多少系统负荷，在这一点上，rsync 就远远不及它了。虽然 rsync 比 scp 会快一点，但当小文件众多的情况下，rsync 会导致硬盘 I/O 非常高，而 scp 基本不影响系统正常使用。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 拷贝文件到远程服务器的指定目录</span>
<span class="token function">scp</span> <span class="token operator">&lt;</span>file<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>user<span class="token operator">&gt;</span>@<span class="token operator">&lt;</span>ip<span class="token operator">&gt;</span>:<span class="token operator">&lt;</span>url<span class="token operator">&gt;</span>
<span class="token function">scp</span> test.txt root@192.168.0.1:/opt

<span class="token comment"># 拷贝目录到远程服务器的指定目录</span>
<span class="token function">scp</span> <span class="token parameter variable">-r</span> <span class="token operator">&lt;</span>folder<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>user<span class="token operator">&gt;</span>@<span class="token operator">&lt;</span>ip<span class="token operator">&gt;</span>:<span class="token operator">&lt;</span>url<span class="token operator">&gt;</span>
<span class="token function">scp</span> <span class="token parameter variable">-r</span> <span class="token builtin class-name">test</span> root@192.168.0.1:/opt
</code></pre></div><h4 id="_3-17-1-免密码传输"><a href="#_3-17-1-免密码传输" class="header-anchor">#</a> 3.17.1. 免密码传输</h4> <p>（1）生成 ssh 公私钥对</p> <div class="language- extra-class"><pre class="language-text"><code>ssh-keygen -t rsa
</code></pre></div><p>（2）将服务器 A 的 <code>\~/.ssh/id_rsa.pub</code> 文件内容复制到服务器 B 的 <code>\~/.ssh/authorized_keys</code> 文件中。</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 服务器 A 上执行以下命令</span>
<span class="token function">scp</span> ~/.ssh/id_rsa.pub root@192.168.0.2:~/.ssh/id_rsa.pub.tmp

<span class="token comment"># 服务器 B 上执行以下命令</span>
<span class="token function">cat</span> ~/.ssh/id_rsa.pub.tmp <span class="token operator">&gt;&gt;</span> ~/.ssh/authorized_keys
<span class="token function">rm</span> ~/.ssh/id_rsa.pub.tmp
</code></pre></div><h3 id="_3-18-mv"><a href="#_3-18-mv" class="header-anchor">#</a> 3.18. mv</h3> <blockquote><p>mv 命令用来对文件或目录重新命名，或者将文件从一个目录移到另一个目录中。source 表示源文件或目录，target 表示目标文件或目录。如果将一个文件移到一个已经存在的目标文件中，则目标文件的内容将被覆盖。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">mv</span> file1.txt /home/office/                      <span class="token comment"># 移动单个文件</span>
<span class="token function">mv</span> file2.txt file3.txt file4.txt /home/office/  <span class="token comment"># 移动多个文件</span>
<span class="token function">mv</span> *.txt /home/office/                          <span class="token comment"># 移动所有 txt 文件</span>
<span class="token function">mv</span> dir1/ /home/office/                          <span class="token comment"># 移动目录</span>
<span class="token function">mv</span> /usr/men/* <span class="token builtin class-name">.</span>                                 <span class="token comment"># 将指定目录中的所有文件移到当前目录中</span>

<span class="token function">mv</span> file1.txt file2.txt          <span class="token comment"># 重命名文件</span>
<span class="token function">mv</span> dir1/ dir2/                  <span class="token comment"># 重命名目录</span>
<span class="token function">mv</span> <span class="token parameter variable">-v</span> *.txt /home/office        <span class="token comment"># 打印移动信息</span>
<span class="token function">mv</span> <span class="token parameter variable">-i</span> file1.txt /home/office    <span class="token comment"># 提示是否覆盖文件</span>

<span class="token function">mv</span> <span class="token parameter variable">-uv</span> *.txt /home/office       <span class="token comment"># 源文件比目标文件新时才执行更新</span>
<span class="token function">mv</span> <span class="token parameter variable">-vn</span> *.txt /home/office       <span class="token comment"># 不要覆盖任何已存在的文件</span>
<span class="token function">mv</span> <span class="token parameter variable">-f</span> *.txt /home/office        <span class="token comment"># 无条件覆盖已经存在的文件</span>
<span class="token function">mv</span> <span class="token parameter variable">-bv</span> *.txt /home/office       <span class="token comment"># 复制时创建备份</span>
</code></pre></div><h3 id="_3-19-rm"><a href="#_3-19-rm" class="header-anchor">#</a> 3.19. rm</h3> <blockquote><p>rm 命令可以删除一个目录中的一个或多个文件或目录，也可以将某个目录及其下属的所有文件及其子目录均删除掉。对于链接文件，只是删除整个链接文件，而原有文件保持不变。</p></blockquote> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">rm</span> test.txt               <span class="token comment"># 删除文件</span>
<span class="token function">rm</span> <span class="token parameter variable">-i</span> test.txt test2.txt  <span class="token comment"># 交互式删除文件</span>
<span class="token function">rm</span> <span class="token parameter variable">-r</span> *                   <span class="token comment"># 删除当前目录下的所有文件和目录</span>
<span class="token function">rm</span> <span class="token parameter variable">-r</span> testdir             <span class="token comment"># 删除目录下的所有文件和目录</span>
<span class="token function">rm</span> <span class="token parameter variable">-rf</span> testdir            <span class="token comment"># 强制删除目录下的所有文件和目录</span>
<span class="token function">rm</span> <span class="token parameter variable">-v</span> testdir             <span class="token comment"># 显示当前删除操作的详情</span>
</code></pre></div></div></div>  <div class="page-edit"><!----> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2023/08/14, 13:28:01</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/vuepress-theme-vdoing-doc/pages/6babae/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">Linux文件压缩和解压要点</div></a> <a href="/vuepress-theme-vdoing-doc/pages/503b98/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">Linux 文件内容查看编辑</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/vuepress-theme-vdoing-doc/pages/6babae/" class="prev">Linux文件压缩和解压要点</a></span> <span class="next"><a href="/vuepress-theme-vdoing-doc/pages/503b98/">Linux 文件内容查看编辑</a>→
      </span></p></div></div></div> <!----></main></div> <div class="footer"><div class="icons"></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2023-2024
    <span>Insist | MIT License</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"></div></div>
    <script src="/vuepress-theme-vdoing-doc/assets/js/app.f061d58b.js" defer></script><script src="/vuepress-theme-vdoing-doc/assets/js/2.9bf30e88.js" defer></script><script src="/vuepress-theme-vdoing-doc/assets/js/71.02806218.js" defer></script>
  </body>
</html>
